package com.caoji.user;

import com.caoji.dto.BaseDTO;
import com.caoji.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description： User: caoji
 * Date: 2020/12/16
 * Time: 14:15
 */

@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class UserDto extends BaseDTO {

    private Long id;
    private String username;
    private String phone;

    public UserDto(BaseEntity entity) {
        super(entity);
    }

    public static <T extends BaseEntity> List<UserDto> convertEntityList(Collection<T> list) {
        if (list == null) {
            return Collections.emptyList();
        }
        return list.stream().map(UserDto::new).collect(Collectors.toList());
    }

}
